import numpy as np

n_classifier = 4
method = 'knn'

result = np.loadtxt('../../data/result/normalsmall_10_16_nn_%d_%s_/recall_l.txt' % (n_classifier, method))


def get_min(recall_l, threshold):
    min_idx_l = np.argsort(recall_l, kind='stable')[:threshold]
    print(min_idx_l)
    min_val_l = [recall_l[_] for _ in min_idx_l]
    print("min_idx:" + str(min_idx_l))
    print("min_val:" + str(min_val_l))
    return min_idx_l, min_val_l


def get_max(recall_l, threshold):
    idx_l = np.argsort(recall_l, kind='stable')
    max_idx_l = np.flipud(idx_l)[:threshold]
    max_val_l = [recall_l[_] for _ in max_idx_l]
    print("max_idx:" + str(max_idx_l))
    print("max_val:" + str(max_val_l))
    return max_idx_l, max_val_l


idx = 10
print("%d %s" % (n_classifier, method))
min_idx, min_val = get_min(result[idx], 10)
max_idx, max_val = get_max(result[idx], 10)
